from imagetools import get_png_info, open_png
import lvgl as lv

decoder = lv.img.decoder_create()
decoder.info_cb = get_png_info
decoder.open_cb = open_png

def showImg(path):
    img1 = lv.img(lv.scr_act())
    img1.set_src(getImg(path))
    img1.align(lv.ALIGN.CENTER, 0,0)
    img1.set_size(240, 240)

def getImg(path):
    try:
        with open(path,'rb') as f:
            png_data = f.read()
    except:
        print("Could not find img_cogwheel_argb.png")
        sys.exit()
    img_cogwheel_argb = lv.img_dsc_t({
      'data_size': len(png_data),
      'data': png_data 
    })
    return img_cogwheel_argb
